#include<bits/stdc++.h>
using namespace std;
int T;
long long n,m,L,V,fastcar,closep;
long long d[3001],v[3001],a[3001],p[100001],usep[100001];
bool car[3001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int z=0;z<T;z++){
        cin>>n>>m>>L>>V;
        fastcar=n;
        for(int i=0;i<n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=0;i<m;i++){
            cin>>p[i];
        }
        for(int i=0;i<n;i++){
            if(a[i]==0){
                if(v[i]<=V){
                    fastcar--;
                    continue;
                }else{
                    for(int j=0;j<m;j++){
                        if(p[j]>d[i]){
                            usep[j-1]=p[j-1];
                            car[i]=1;
                            break;
                        }
                    }
                }
            }
            double vp;
            if(a[i]==0){
                vp=L-d[i];
            }else{
                vp=(pow(V,2)-pow(v[i],2))/(2*a[i]);
            }
            for(int j=0;j<m;j++){
                if(p[j]<d[i]&&p[j+1]>d[i]+vp){
                    //cout<<i<<" ";
                    fastcar--;
                    break;
                }else if(car[i]==0){
                    usep[j]=p[j];
                    car[i]=1;
                }
            }
        }
        for(int j=0;j<m;j++){
            if(usep[j]==0){
                closep++;
            }
        }
        cout<<fastcar<<" "<<closep<<endl;
    }
    return 0;
}
